/**
 * 原数组对象 obj，期待处理成如下格式 obj2
 */
let obj2 = [
  { name: 'aaa', age: 18, city: 'beijing' },
  { name: 'bbb', age: 21, city: 'shanghai' },
  { name: 'ccc', age: 16, city: 'guangzhou' },
]

{
  let obj = {
    name: ['aaa', 'bbb', 'ccc'],
    age: [18, 21, 16],
    city: ['beijing', 'shanghai', 'guangzhou'],
  }
  let result = []
  for (const key in Object.values(obj)[0]) {
    let res = Object.keys(obj).reduce((prev, curr) => {
      prev[curr] = obj[curr][key]
      return prev
    }, {})
    result.push(res)
  }
  console.log(result)
}

{
  let obj = {
    name: ['aaa', 'bbb', 'ccc'],
    age: [18, 21, 16],
    city: ['beijing', 'shanghai', 'guangzhou'],
  }
  let convert = data => {
    return Array.from({ length: Object.values(data)[0].length }).map((r, i) => {
      return Object.keys(data).reduce((total, key) => {
        total[key] = data[key][i]
        console.log(total)
        return total
      }, {})
    })
  }
  // console.log(convert(obj))
}
